package com.ws.process;

import java.util.Scanner;

/*
如何从键盘获取不同类型的变量：需要使用 Scanner 类
1.导包 import java.util.Scanner;
2.Scanner 的实例化 Scanner scan = new Scanner(System.in);

 */
public class ScannerTest {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        System.out.print("请输入你的姓名：");
        String name = scan.next();
        System.out.println(name);

        char lastName = name.charAt(0); //取索引为 0 位置上的字符
        System.out.println(lastName);

        System.out.print("请输入你的年龄：");
        int num = scan.nextInt();
        System.out.println(num);

        System.out.println("请输入你的体重：");
        double weight = scan.nextDouble();
        System.out.println(weight);


        scan.close();
    }
}
